<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

/**
 *
 *
 *
 * @package     ceo
 * @subpackage  models
 * @category    models
 * @author      ydd team, wu
 * @copyright   copyright (c) 2012, yaoduoduo, Inc.
 * @filesource
 */
class Market_model extends Base_model {

    protected $_table_name = 'h_market_research';
    protected $_key_name = 'market_research_id';



    
    function get_object_has_c_id() {

        $this->db->where('client_id > ' ,0);
        $q=$this->db->get($this->_table_name);
        return $q;

    }    

    function get($id) {

        $this->db->where($this->_key_name ,$id);
		return $this->db->get($this->_table_name);
    }

    function get_c_all() {
        $this->set_limit("20", "0");
        $res = $this->db->get($this->_table_name);
        return $res;
    }
	
	function get_all2() {
        
        $res = $this->db->get($this->_table_name);
        return $res;
    }

    function get_fields() {

        $fields = $this->db->list_fields($this->_table_name);
        return $fields;
    }
	
	function get_oo_object($id) {
		
		$sql = "SELECT * FROM `h_market_research` WHERE `object_id` = '".$id."'";
		$r = $this->db->query($sql);
		return $r;
	}
	
    function get_object_info_by_victor($id) {

        $this->db->where($this->_key_name, $id);
        $res = $this->db->get($this->_table_name);
		return $res;
		/*
        if ($res->num_rows() > 0) {

            return $res;
        } else {
            return false;
        }
		 */
    }

    function get_one_object_info($id) {

        $this->db->where("object_id", $id);
        $query = $this->db->get("market_research");
        return $query;
    }

    function do_excel_info($ids) {
        if ($ids) {
            foreach ($ids as $num => $id) {
                $this->db->or_where("object_id", $id);
            }
        }
        $query = $this->db->get("market_research");

        return $query;
    }

    function get_object_name($name) {
        if (!empty($name))
            $where["name"] = $name;
        $user_purview = check_broker_is_visible();
        if (!$user_purview) {
            $this->set_or_like('front_man,broker', $this->login_lib->users_name());
        }
        $where['dtime'] = 0;
        return $this->fetch(NULL, $where, NULL, 'row');
    }

    function get_object_name_count($name) {
        if ($name != "")
            $where["name"] = $name;
        $user_purview = check_broker_is_visible();
        if (!$user_purview) {
            $this->set_or_like('front_man,broker', $this->login_lib->users_name());
        }
        $where['dtime'] = 0;
        return $this->fetch(NULL, $where, NULL, 'count');
    }


    //取得欄位
    function get_field() {        

        return $this->db->list_fields($this->_table_name);        
    }

    //個人erson
    function get_object_person_excel() {        
        
        //是否經紀人
        

        $CI = &get_instance();
        $purview = $CI->login_lib->purview();
        $users_id = $CI->login_lib->users_id();

        if ($purview!='#all') {

            //$this->db->where('front_man', $users_id);
            $this->db->where('broker', $users_id);
        }


        $res = $this->db->get($this->_table_name);
        return $res;
    }


    //company excel
    function get_object_company_excel($fiels) {


        $ff_flag=true;
        $_sel_str='';
        foreach($fiels as $_k =>$f_name){

            if($ff_flag){
                $ff_flag=false;
                $_sel_str.=$f_name;
            }else{
                $_sel_str.=",".$f_name;
            }

        }
        
        $this->db->select($_sel_str);

        


        $res = $this->db->get($this->_table_name);
        return $res;
    }



    function get_object_by_person($fields) {

        $q=$this->db->get($this->_table_name);
        return $q;
    }    

    function get_object($uri_query, $limit) {
        $this->set_limit($limit);
        $user_purview = check_broker_is_visible();
        if (!$user_purview) {
            $this->set_or_like('front_man,broker', $this->login_lib->users_name());
        }
        $where = array('dtime' => 0, 'name' => $uri_query['keyword']);
        return $this->fetch(NULL, $where);
    }

    function get_object_count($uri_query) {
        $user_purview = check_broker_is_visible();
        if (!$user_purview) {
            $this->set_or_like('front_man,broker', $this->login_lib->users_name());
        }
        $con["where"][] = array('dtime' => 0, 'name' => $uri_query['keyword']);
        $this->set_args_array($con);
        return $this->fetch_count();
    }

    function get_all() {
        $user_purview = check_broker_is_visible();
        if (!$user_purview) {
            //$this->set_or_like('front_man,broker', $this->login_lib->users_name());
        }
        $where = array('dtime' => 0);
        return $this->fetch(NULL, $where);
    }



    function get_all_object() {
        
        $CI = &get_instance();
        $purview = $CI->login_lib->purview();
        $users_id = $CI->login_lib->users_id();

        if ($purview!='#all') {

            //$this->db->where('front_man', $users_id);
            $this->db->where('broker', $users_id);
        }


        

        $p=$this->db->get($this->_table_name);
        return $p;

    }

    //配對
    function match_object($where, $limit = false) {

        $test_flag = false;




        foreach ($where as $name => $value) {



            //不要查詢
            if ($name != 'front_man' AND
                    //object_usage
                    $name != 'leasing_business_purposes' AND
                    $name != 'object_usage' AND
                    $name != 'shop_point_id' AND
                    //$name != 'total_budget2' AND
                    $name != 'remark' AND
                    $name != 'required_level' AND
                    $name != 'object_id' AND
                    $name != 'demand_id' AND
                    $name != 'sections1' AND
                    $name != 'sections2' AND
                    //$name != 'total_budget1' AND
                    $name != 'indoor_area1' AND
                    $name != 'indoor_area2' AND
                    $name != 'mrt_until1' AND
                    $name != 'mrt_start1' AND
                    $name != 'mrt_until2' AND
                    $name != 'range_east' AND
                    $name != 'mrt_start2' AND
                    $name != 'mrt_line2' AND
                    $name != 'name' AND
                    $name != 'demand_id' AND
                    $name != 'currency' AND
                    $name != 'ctime' AND
                    $name != 'mobile' AND
                    $name != 'home_phone' AND
                    $name != 'company_phone' AND
                    $name != 'home_address' AND
                    $name != 'company_address' AND
                    $name != 'company_name' AND
                    $name != 'email' AND
                    $name != 'object_name1' AND
                    $name != 'object_name2' AND
                    $name != 'contact' AND
                    $name != 'contact_phone' AND
                    $name != 'acceptable_mechanical' AND
                    $name != 'area_unit'
            ) {

                if ($test_flag) {

                    echo '<font color=red>' . $name . ' </font>';
                    echo '=>';
                    echo '<font color=blue>' . $value . '</font>';
                    echo "<br>";
                }


                //ok-indoor_pattern_house  房數      number_of_rooms1/number_of_rooms2
                //indoor_pattern_hall   廳數      number_of_hall1/number_of_hall2
                //indoor_pattern_guard  衛數      number_of_toilet1/number_of_toilet2
                //indoor_pattern_suite  套房數     number_of_suite1/number_of_suite1

                if ($name == "object_case_type") {

                    //物件案別  1中古屋  2預售  3標售
                    //if (is_array($value)) {
                    $_str = explode("/", $value);
                    foreach ($_str as $a_flag => $a_val) {

                        //echo $a_flag .'=>'. $a_val;

                        $this->db->like("object_case_type", $a_val);
                    }
                } elseif ($name == "total_budget1") {

                    $this->db->where("sale_total >=", $value);
                } elseif ($name == "total_budget2") {

                    $this->db->where("sale_total <=", $value);
                } elseif ($name == "type_sell") {


                    $this->db->where("type_sale", $value);
                } elseif ($name == "type_rent") {

                    $this->db->where("type_rent", $value);
                } elseif ($name == "land_area1") {

                    $this->db->where("stakeholders_land_area >= ", $value);
                } elseif ($name == "land_area2") {

                    $this->db->where("stakeholders_land_area <= ", $value);
                } elseif ($name == "type_consignment") {

                    $this->db->where("type_help_seal", $value);
                } elseif ($name == "year_of_construction") {

                    $this->db->where("year_of_construction <= ", $value);
                } elseif ($name == "number_of_suite1") {
                    //套房數
                    $this->db->where("indoor_pattern_suite >= ", $value);
                } elseif ($name == "number_of_suite2") {
                    //套房數
                    $this->db->where("indoor_pattern_suite <= ", $value);
                } elseif ($name == "number_of_toilet1") {
                    //衛數
                    $this->db->where("indoor_pattern_guard >= ", $value);
                } elseif ($name == "number_of_toilet2") {
                    //衛數
                    $this->db->where("indoor_pattern_guard <= ", $value);
                } elseif ($name == "number_of_hall1") {
                    //廳數
                    $this->db->where("indoor_pattern_hall >= ", $value);
                } elseif ($name == "number_of_hall2") {
                    //廳數
                    $this->db->where("indoor_pattern_hall <= ", $value);
                } elseif ($name == "number_of_rooms1") {
                    //房數
                    $this->db->where("indoor_pattern_house >= ", $value);
                } elseif ($name == "number_of_rooms2") {
                    //房數
                    $this->db->where("indoor_pattern_house <= ", $value);
                } elseif ($name == "facing_the_household") {

                    $this->db->where("base_is_located1", $value);
                } elseif ($name == "building_facing") {

                    $this->db->where("base_is_located2", $value);
                } elseif ($name == "object_case_type") {
                    //中古屋  預售  標售
                    $this->db->where("object_case_type", $value);
                } elseif ($name == "budget_per_ping1") {

                    $this->db->where("sale_land_unit_price >= ", $value);
                } elseif ($name == "budget_per_ping2") {

                    $this->db->where("sale_land_unit_price <= ", $value);
                } elseif ($name == "specify_building1") {

                    $this->db->like("case_name", $value);
                } elseif ($name == "specify_building2") {

                    $this->db->like("case_name", $value);
                } elseif ($name == "building_area1") {

                    $this->db->where("building_area >= ", $value);
                } elseif ($name == "building_area2") {

                    $this->db->where("building_area <= ", $value);
                } elseif ($name == "parking_number") {

                    $this->db->where("parking_number1 >= ", $value);
                    $this->db->where("parking_number2 >= ", $value);
                } elseif ($name == "key_areas1") {

                    $this->db->like("area", $value);
                } elseif ($name == "key_areas2") {

                    $this->db->like("area", $value);
                } else {
                    //$this->db->where($name,$value);
                }
            }
        }

        //$this->db->where($where);
        if (!empty($limit)) {
            //$this->db->limit($limit);
            $this->set_limit($limit);
        }
        $this->db->order_by("ctime", "DESC");
        $query = $this->db->get("object");
        return $query;
    }

    function object_pair($where = null, $w = null, $limit) {
        $this->set_limit($limit);
        $user_purview = check_broker_is_visible();
        if (!$user_purview) {
            $this->set_or_like('front_man,broker', $this->login_lib->users_name());
        }
        if (isset($w['key_areas']))
            $this->db->where_in('area', $w['key_areas']);
        if (isset($w['sections1']))
            $this->set_or_like('house_building', $w['sections1']);
        if (isset($w['object_name']))
            $this->db->where_in('case_name', $w['object_name']);
        if (isset($w['administrative_area']))
            $this->db->where_in('administrative_area', $w['administrative_area']);



        $where['dtime'] = 0;
        return $this->fetch(NULL, $where);
    }

    function object_pair_count($where = null, $w = null) {
        $user_purview = check_broker_is_visible();
        if (!$user_purview) {
            $this->set_or_like('front_man,broker', $this->login_lib->users_name());
        }
        $where['dtime'] = 0;
        return $this->fetch(NULL, $where, NULL, "count");
    }

    function get_object_case_name() {
        $user_purview = check_broker_is_visible();
        if (!$user_purview) {
            $this->set_or_like('front_man,broker', $this->login_lib->users_name());
        }
        $where['dtime'] = 0;
        $result = $this->fetch(NULL, $where);
        $this->load->model('building_name_model');
        $building_name = $this->building_name_model->get_building_name();
        $p = array();
        foreach ($result as $key => $val) {
            $p[$val->object_id]["object_no"] = $val->object_no;
            if (isset($building_name[$val->case_name]))
                $p[$val->object_id]["case_name"] = $building_name[$val->case_name];
            else
                $p[$val->object_id]["case_name"] = $val->case_name;
        }
        return $p;
    }

    function query_object($w = null, $keyword = null, $limit) {


        $this->db->order_by("ctime", "DESC");
        $this->set_limit($limit);

        if ($keyword != "")
            $this->set_or_like('name', $keyword);
        if (isset($w['name']))
            $this->set_or_like('name', $w['name']);
        if (isset($w['principal']))
            $this->set_or_like('principal', $w['principal']);


        if (isset($w['type_rent'])) {
            $this->db->or_where('type_rent', $w['type_rent']);
        }

        if (isset($w['type_sale'])) {
            $this->db->or_where('type_sale', $w['type_sale']);
        }

        if (isset($w['type_help_seal'])) {
            $this->db->or_where('type_help_seal', $w['type_help_seal']);
        }


        if (isset($w['administrative_area'])) {
            $this->db->like('administrative_area', $w['administrative_area']);
        }
        if (isset($w['house_building'])) {
            $this->db->like('house_building', $w['house_building']);
        }
        /*
          if (isset($w['type'])) {
          if ($w['type'] == 1)
          $where['type_rent'] = 1;
          else if ($w['type'] == 2)
          $where['type_sale'] = 1;
          else if ($w['type'] == 3)
          $where['type_help_seal'] = 1;
          }
         */
        if (isset($w['house_building']))
            $this->set_or_like('house_building', $w['house_building']);

        if (isset($w['area'])) {
            //$this->like('area', $w['area']);
            $where['area'] = $w['area'];
        }

        if (isset($w['case_name']))
            $where['case_name'] = $w['case_name'];
        if (isset($w['building_name']))
            $where['building_name'] = $w['building_name'];
        if (isset($w['object_usage']))
            $where['object_usage'] = $w['object_usage'];
        if (isset($w['object_state']))
            $where['object_state'] = $w['object_state'];

        if (isset($w['object_case_type'])) {
            //echo $w['object_case_type'];
            $this->set_or_like('object_case_type', $w['object_case_type']);
            //$where['object_case_type'] = $w['object_case_type'];
        }

        //建物面積
        if (!empty($w['building_area1']))
            $where['building_area >='] = $w['building_area1'];
        //建物面積
        if (!empty($w['building_area2']))
            $where['building_area <='] = $w['building_area2'];

        if (isset($w['base_area1']))
            $where['base_area >='] = $w['base_area1'];
        if (isset($w['base_area2']))
            $where['base_area <='] = $w['base_area2'];

        if (isset($w['owner']))
            $where['owner'] = $w['owner'];


        //總價1
        if (isset($w['total1'])) {

            //if($w['type']==1)
            //    $where['type_rent']=1;
            //else if($w['type']==2)
            $where['sale_total >='] = $w['total1'];
        }

        //總價2
        if (isset($w['total2']))
            $where['sale_total <='] = $w['total2'];

        if (isset($w['latitude1']))
            $where['location_map1 >='] = $w['latitude1'];
        if (isset($w['latitude2']))
            $where['location_map1 <='] = $w['latitude2'];
        if (isset($w['longitude1']))
            $where['location_map2 >='] = $w['longitude1'];
        if (isset($w['longitude2']))
            $where['location_map2 <='] = $w['longitude2'];
        if (isset($w['year_of_construction1']))
            $where['year_of_construction >='] = $w['year_of_construction1'];
        if (isset($w['year_of_construction2']))
            $where['year_of_construction <='] = $w['year_of_construction2'];
        if (isset($w['broker']))
            $this->set_or_like('broker', $w['broker']);



        /*
          if(isset($w['entrust_start1']))
          $where[' >='] =$w['entrust_start1'];
          if(isset($w['entrust_start2']))
          $where[' <='] =$w['entrust_start2'];
          if(isset($w['entrust_end1']))
          $where[' >='] =$w['entrust_end1'];
          if(isset($w['entrust_end2']))
          $where[' <='] =$w['entrust_end2'];
         */

        if (isset($w['orderby']))
            $this->db->order_by($w['orderby'], $w['sort']);
        if (isset($w['bcc']))
            $where['bcc'] = $w['bcc'];
        if (isset($w['object_no']))
            $this->set_or_like('object_no', $w['object_no']);
        if (isset($w['floor1']))
            $where['floor >='] = $w['floor1'];
        if (isset($w['floor2']))
            $where['floor <='] = $w['floor2'];


        if (isset($w['sctime'])) {

            $ts = explode("/", $w['sctime']);
            $where['ctime >='] = mktime(0, 0, 0, $ts[1], $ts[2], $ts[0]);
        }

        if (isset($w['ectime'])) {

            $te = explode("/", $w['ectime']);
            $where['ctime <='] = mktime(23, 59, 59, $te[1], $te[2], $te[0]);
        }
        if (isset($w['broker']))
            $this->set_or_like('broker', $w['broker']);

        $user_purview = check_broker_is_visible();

        if (!$user_purview) {

            $this->set_or_like('front_man,broker', $this->login_lib->users_name());
        }

        //$where['dtime'] = 0;
        //print_r($where);
        //print_r($where);

        if (empty($where)) {

            $qe = $this->db->get($this->_table_name);
            return $qe->result();
        } else {
            return $this->fetch(NULL, $where);
        }
    }

    function query_object_count($w = null, $keyword = nulls) {
        if ($keyword != "")
            $this->set_or_like('name', $keyword);
        if (isset($w['name']))
            $this->set_or_like('name', $w['name']);
        $user_purview = check_broker_is_visible();
        if (!$user_purview) {
            $this->set_or_like('front_man,broker', $this->login_lib->users_name());
        }
        if (isset($w['sctime'])) {
            $ts = explode("/", $w['sctime']);
            $where['ctime >='] = mktime(0, 0, 0, $ts[1], $ts[2], $ts[0]);
        }
        if (isset($w['ectime'])) {
            $te = explode("/", $w['ectime']);
            $where['ctime <='] = mktime(23, 59, 59, $te[1], $te[2], $te[0]);
        }
        if (isset($w['broker']))
            $this->set_or_like('broker', $w['broker']);
        $user_purview = check_broker_is_visible();
        if (!$user_purview) {
            $this->set_or_like('front_man,broker', $this->login_lib->users_name());
        }
        $where['dtime'] = 0;
        return $this->fetch(NULL, $where, NULL, "count");
    }

    function update_object($data, $id) {

        $this->db->where($this->_key_name, $id);
        $this->db->update($this->_table_name, $data);
        //$where[] = array('object_id' => $id);
        //return $this->update($data, $where);
    }

    function update_object_point_count($id) {

        $sql = "UPDATE  `h_object` SET  `point_count` =  `point_count` +1 WHERE  `object_id` = $id";
        $this->db->query($sql);
    }

    function add_object($data) {

        $data['shop_point_id'] = $this->login_lib->shop_point_id();
        $data['ctime'] = time();

        return $this->insert($data);
    }

    function add_object_history($data, $id) {

        $query = $this->db->get_where('h_object_history', array('object_id' => $id));
        //$que=$query->result();

        $data['shop_point_id'] = $this->login_lib->shop_point_id();
        $data['ctime'] = time();
        $data['object_id'] = $id;
        $data['version'] = $query->num_rows() + 1;

        $this->db->insert('h_object_history', $data);
    }

    function insert_of_type_object($data) {

        //$data['shop_point_id'] = $this->login_lib->shop_point_id();
        //$data['ctime'] = time();
        //print_r($data);
        if (!empty($data["type_rent"]) AND $data["type_rent"] == 1) {

            foreach ($data as $key => $val) {
                if ($key != "type_help_seal" &&
                        $key != "type_sale")
                    $ds[$key] = $val;
            }

            $ds['ctime'] = time();
            $this->db->insert('h_market_research',$ds);
        }

        if (!empty($data["type_sale"]) AND $data["type_sale"] == 1) {

            foreach ($data as $key => $val) {

                if ($key == "type_rent" OR $key == "type_help_seal") {
                    $ds[$key] = 0;
                } else {
                    $ds[$key] = $val;
                }
            }

            $ds['ctime'] = time();
            $this->db->insert('h_market_research',$ds);
        }

        if (!empty($data["type_help_seal"]) AND $data["type_help_seal"] == 1) {

            foreach ($data as $key => $val) {
                if ($key == "type_rent" OR $key == "type_sale") {
                    $ds[$key] = 0;
                } else {
                    $ds[$key] = $val;
                }
            }

            $ds['ctime'] = time();
            $this->db->insert('h_market_research',$ds);
        }

        if (empty($data["type_help_seal"]) AND
                empty($data["type_sale"]) AND
                empty($data["type_rent"])) {

            foreach ($data as $key => $val) {
                if ($key == "type_rent" OR $key == "type_sale") {
                    $ds[$key] = 0;
                } else {
                    $ds[$key] = $val;
                }
            }

            $ds['ctime'] = time();
            $this->db->insert('h_market_research',$ds);
        }
    }

    function del_object_session($id) {

        $this->db->where($this->_key_name, $id);
        $this->db->delete($this->_table_name);
    }

    function del_object($data) {
        $where[] = array('object_id' => $data['id']);
        $value = array('dtime' => time());
        return $this->update($value, $where);
    }

    function copy_object($data) {

        //echo $data['object_id'];
        $this->db->where($this->_key_name , $data['object_id']);
        $qeruy_q=$this->db->get("h_object");
        $d;
        foreach($qeruy_q->result_array() as $rd){
            $d=$rd;
        }

        //$d["head"] = $data["head"];
        //$d["broker"] = $data["broker"];
        //$d["front_man"] = $data["front_man"];
        //$d['object_id'] = "";
        //$d["client_id"] = $data["client_id"];

        //$d['ref_client_verify_code'] = $data["ref_client_verify_code"];
        //$d['owner'] = $data["name"];
        //$d['owner_mobile'] = $data["mobile"];
        //$d['owner_phone'] = $data["phone"];
        $d['ctime'] = time();
        $d['point_count'] = '';
        //print_r($d);
        return $this->add_object($d);
    }


    function copy_object2($data,$id) {

        //echo $data['object_id'];
        $this->db->where($this->_key_name , $id);
        $qeruy_q=$this->db->get("h_object");

        $d=array();
        $d2=array();

        foreach($qeruy_q->result_array() as $rd){
            $d=$rd;
        }

        foreach($d as $name => $value ){
            //echo $name .'=>'. $value.'<br>';
            if($name!='object_id')
            $d2[$name] =$value;
        }

        $d2["head"] = $data["head"];
        $d2["broker"] = $data["broker"];
        $d2["front_man"] = $data["front_man"];
        //$d2['object_id'] = "";
        $d2["client_id"] = $data["client_id"];

        $d2['ref_client_verify_code'] = $data["ref_client_verify_code"];

        $d2['ctime'] = time();
        $d2['point_count'] = '';
        //print_r($d2);
        return $this->add_object($d2);
    }

    function object_match_demand($where) {


        $this->db->where($where);
        $query = $this->db->get("demand");

        return $query;
    }

    function object_match($where) {


        $this->db->where($where);
        $query = $this->db->get("market_research");

        return $query;
    }

    function get_object_id($id) {


        $this->db->where("object_id", $id);
        $query = $this->db->get("market_research");

        return $query;
    }

    function countRec($table_name, $query) {

        $sql = " SELECT count(*) as `count` FROM `h_market_research` " . $query;

        $query = $this->db->query($sql);

        $total;

        foreach ($query->result() as $row) {
            $total = $row->count;
        }

        return $total;
    }

    function object_for_crid($page, $rp, $sortname, $sortorder, $query) {


        $roder_by = " ORDER BY  `" . $sortname . "` " . $sortorder . " ";
        $start = (($page - 1) * $rp);
        $limit = " LIMIT $start, $rp";

        $sql_round =  " SELECT * FROM  " ."  `h_market_research` " .
                      $query . " " .
                      $roder_by . " " .
                      $limit;

        //$this->db->insert("h_sql" , array("SQL" => $sql_round));

        $total_rows = $this->countRec("h_market_research", $query);

        $query = $this->db->query($sql_round);
        return $query;
    }

    function object_for_crid_another($page
    , $rp
    , $sortname
    , $sortorder
    , $query) {



        $roder_by = " ORDER BY  `" . $sortname . "` " . $sortorder . " ";

        $start = (($page - 1) * $rp);
        $limit = "LIMIT $start, $rp";

        $sql_round = 	" SELECT * FROM  " .
		                "  `h_market_research` " .
		                $query . " " .
		                $roder_by . " " .
		                $limit;

        //$this->load->model('insert_model');

        $sql_data = array('SQL' => $where);
        //$this->insert_model->insert_to_sql($sql_round, 'h_sql');

        $total_rows = $this->countRec("h_object", $query);

        $query = $this->db->query($sql_round);
        return $query;
    }
	
	function insert_test_data(){
		
		$sql ="INSERT INTO `h_market_research` ( `ref_client_verify_code`, `client_contact_id`, `point_count`, `shop_point_id`, `client_id`, `market_survey_no`, `object_no`, `object_state`, `type_rent`, `type_sale`, `type_help_seal`, `owner`, `owner_mobile`, `owner_phone`, `owner_phone_type`, `principal`, `principal_mobile`, `principal_phone`, `principal_phone_type`, `market_research_status`, `case_name`, `building_name`, `object_usage`, `object_styles`, `administrative_area`, `house_building`, `area`, `build_number`, `sale_total`, `sale_parking`, `sale_housing_prices`, `sale_housing_unit_price`, `sale_parking_price`, `sale_parking_unit_price`, `sale_land_unit_price`, `rent_total`, `rent_tax`, `rent_parking`, `rent_housing_rent`, `rent_parking_space_rentals`, `rent_rent_per_ping`, `rent_monthly_rent_parking_spaces`, `rent_deposit_month`, `rent_deposit_money`, `rent_min`, `rent_max`, `rent_lease_hike`, `rent_rent_free_period_decoration`, `rent_ancillary`, `rent_notarization`, `building_area`, `main_building_area`, `subsidiary_building_area`, `postulate`, `total_weight_shaped_area`, `with_parking_number`, `parking_area`, `parking_area_number`, `use_area`, `postulate_than`, `base_is_located1`, `base_is_located2`, `to_no`, `base_area`, `scope_of_rights1`, `scope_of_rights2`, `stakeholders_land_area`, `present_value`, `total_present_value1`, `total_present_value2`, `land_use_zoning`, `volume_rate`, `building_coverage_ratio`, `monthly_management_fee`, `management_fees_per_ping`, `management`, `attached_configuration`, `indoor_pattern_house`, `indoor_pattern_hall`, `indoor_pattern_guard`, `indoor_pattern_suite`, `windows`, `household_door`, `building_entrance`, `households`, `building_households`, `total_towers`, `total_households`, `floor`, `floor_plan1`, `floor_plan2`, `number_of_lifts1`, `number_of_lifts2`, `facing_the_lane`, `use_status`, `lease_maturity`, `lessee_by_industry`, `floor_height`, `building_exterior`, `main_building`, `building_completion_date`, `year_of_construction`, `annual_rent`, `reported_rate`, `construction_company`, `construction_license_no`, `look_mode`, `key_management`, `location_map1`, `location_map2`, `currency`, `area_unit`, `bank_set_total_amount`, `loan_bank`, `other_settings_amount`, `bring_own_money`, `estimated_loan`, `environmental_features`, `object_features`, `public_facilities`, `fire_and_security`, `circle1`, `circle2`, `park1`, `park2`, `mrt_line1`, `mrt1`, `mrt_line2`, `mrt2`, `school_district_primary`, `school_district_high`, `school_district_senior`, `spaces_where_floor`, `parking_numbers`, `parking_entrance_height`, `public_parking_spaces1`, `public_parking_spaces2`, `separate_parking1`, `separate_parking2`, `car_park_management_fee`, `total_management_fee_parking`, `parking_type1`, `parking_number1`, `parking_price1`, `parking_type2`, `parking_number2`, `parking_price2`, `use_parking_number`, `ballot`, `subsidiary_sun_area`, `subsidiary_flower_sun`, `subsidiary_falt_sun`, `subsidiary_terrace_flat`, `subsidiary_no_sun`, `subsidiary_subsid_other`, `pubilc_set_p_main`, `pubilc_set_p_big`, `pubilc_set_p_small`, `main_build_area_isfloor`, `main_build_area_main_area`, `main_build_area_staircases`, `main_build_area_m_b_other`, `inside_crid_troom`, `inside_crid_inside_room`, `inside_crid_livingroom`, `inside_crid_restroom`, `inside_crid_bookroom`, `inside_crid_manageroom`, `inside_crid_closeroom`, `inside_crid_saveroom`, `inside_crid_otherroom`, `t_use_area_courtyard_area`, `t_use_area_basement`, `t_use_area_terrace`, `t_use_area_additional`, `internet`, `valuation_date`, `valuation_amount`, `appraisal_agencies`, `object_case_type`, `transaction_prices_near`, `bcc`, `status`, `invalid_description`, `remark`, `front_man`, `head`, `assigned_date`, `broker`, `ctime`, `mtime`, `dtime`) VALUES
( '6aea58e32be363175c8635252468f034', 587, 0, 0, 39, '123123', '', '', 0, 1, 0, '', '', '', 0, '', '', '', 0, '', '', '', '', '', '', '', '', '', '0.00', 0, 0, 0, 0, 0, 0, 0, 0, 0, '0.00', '0.00', '0.00', '0.00', 0, '0.00', 0, 0, '', '', '', 0, 0, 0, '', '', '', 0, '0.00', 0, '0.00', '0.00', '', 0, '', 0, '', '', '0.00', '0.00', '0.00', 0, '', '0.00', '0.00', '0.00', '0.00', '', '', 0, 0, 0, 0, '', '', '', '', '', 0, 0, 0, 0, 0, 0, 0, '0.00', '', '', '', '0.00', '', '', '', 0, '0.00', '0.00', '', '', '', '', '', '', 2, 1, '0.00', '', '0.00', '0.00', '0.00', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '0.00', '0.00', 0, '', 0, '0.00', '0.00', 0, 0, '0.00', 0, 0, '0.00', 0, '', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, '', '0.00', '', '1', '0.00', 'N', 1, '', '123123', '3', '14', '', '3', 1400744645, 0, 0);";
		$this->db->query($sql);
			
	}
}
